import {CreateVideoDto} from './dto/create-video.dto'
import {UpdateVideoDto} from './dto/update-video.dto'

import {Injectable} from '@nestjs/common';
import {InjectRepository} from '@nestjs/typeorm';
import {Repository,getConnection } from 'typeorm';
import {video} from './entities/video.entity'

@Injectable()
export class VideoService {
    constructor(
        @InjectRepository(video)
        private videoRepository: Repository<video>,
    ) {
    }


   async create(createVideoDto: CreateVideoDto) {
        let name=createVideoDto.name
        let location =createVideoDto.location
        let content=createVideoDto.content
        let type=createVideoDto.type
        let updateTime=createVideoDto.updateTime







        await getConnection()
            .createQueryBuilder()
            .insert()
            .into(video)
            .values([{ firstName:video.name, lastName: name }])
            .execute();

        return 'uploadsuccess'
    }

    findAll() {
        return `This action returns all video`
    }

    findOne(id: number) {
        console.log('-----------------' + id)
        return this.videoRepository.findOne(id)
    }

    update(id: number, updateVideoDto: UpdateVideoDto) {
        return `This action updates a #${id} video`
    }

    remove(id: number) {
        return `This action removes a #${id} video`
    }
}
